/***************************************** 
 * Desc: UGUI图片组件，此组件不可交互，需要纯图片展示的情况下才使用，否则使用Panel
 * @Author: GSan
 * @Email: 2087653648@qq.com
 * CreateDate: 2020-07-11 16:29:06
*****************************************/

using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

namespace Common.UGUI.View {
    
    public class UGUIImage : UGUIPanel {

        #region 域

        public override bool IsInteractable {
            get {
                return false;
            }
            set {
            }
        }

        #endregion

        #region Unity生命周期

        protected override void OnAwake() {

            _isInteractable = false;

            Image.raycastTarget = _isInteractable;
        }


        #endregion

        #region 覆盖父类函数

        public override void SetActive(bool isActive) {

            _isActive = isActive;

            if (isActive) {

                if (OnEnable != null) {

                    OnEnable();
                }

                Image.rectTransform.localScale = _originalScale;
            } else {

                if (OnDisable != null) {

                    OnDisable();
                }

                Image.rectTransform.localScale = Vector3.zero;
            }
        }

        #endregion

        #region UI事件相关函数

        public override void OnPointerDown(PointerEventData eventData) { Debug.LogError("UGUIImage can't accept event, you must set raycastTarget to false or may be you need use UGUIPanel."); }

        public override void OnPointerClick(PointerEventData eventData) { Debug.LogError("UGUIImage can't accept event, you must set raycastTarget to false or may be you need use UGUIPanel."); }

        public override void OnPointerUp(PointerEventData eventData) { Debug.LogError("UGUIImage can't accept event, you must set raycastTarget to false or may be you need use UGUIPanel."); }

        public override void OnPointerEnter(PointerEventData eventData) { Debug.LogError("UGUIImage can't accept event, you must set raycastTarget to false or may be you need use UGUIPanel."); }

        public override void OnPointerExit(PointerEventData eventData) { Debug.LogError("UGUIImage can't accept event, you must set raycastTarget to false or may be you need use UGUIPanel."); }

        #endregion
    }
}
